package GUI;

import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Font;
import java.util.ArrayList;

import javax.swing.JTextArea;
import javax.swing.SwingConstants;

import MessagePacks.MessageNotificationPack;
import entities.NotificationMessage;

/**
 *@author Juan Alapin - 324507516
 *@author Giora Yaffe - 036551281
 *@author Shachar Gritzman - 300174026
 *@author Nir Porat - 021515580
*/

public class WatchMessages extends MasterGUI{
	
	private MainGUI maingui;
	private ArrayList<NotificationMessage> NM;
	private NotificationMessage messages;
	private static final long serialVersionUID = 1L;
	private JTextArea textAreaMessages;
	private String get;

	public WatchMessages(MainGUI maingui) {
		super(maingui);
		this.maingui=maingui;
		
		MessageNotificationPack msgpck = new MessageNotificationPack(null,maingui.usr.GetUser());
		
		maingui.client.handleMessageFromClientUI(msgpck);
		MessageNotificationPack msgs=(MessageNotificationPack) maingui.client.getMessage();
		NM =  msgs.getMsgs();
		
		
		JPanel panel = new JPanel();
		panel.setBounds(0, 0, 884, 40);
		getContentPane().add(panel);
		
		JLabel lblWatchMessages = new JLabel("Watch Messages");
		lblWatchMessages.setFont(new Font("Dialog", Font.BOLD, 16));
		panel.add(lblWatchMessages);
		
		JLabel lblMessages = new JLabel("Messages :");
		lblMessages.setHorizontalAlignment(SwingConstants.RIGHT);
		lblMessages.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblMessages.setBounds(25, 63, 103, 23);
		getContentPane().add(lblMessages);
		
		textAreaMessages = new JTextArea("");
		textAreaMessages.setBounds(25, 97, 837, 331);
		getContentPane().add(textAreaMessages);
		
		for (NotificationMessage msg : NM)
		{
			if (msg.getread() == false){		 
			textAreaMessages.setText("Message- " + msg.getmID() + " : " + msg.getmsg() + "\n");	
			}
		}
	}
}
